package com.tbm.prode.services;

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import com.tbm.prode.model.User;

public class SimpleUserService implements UserService {
	
	private User currentUser;

	@Override
	public User getCurrentUser() {
		return currentUser;
	}

	@Override
	public User authenticate(String username, String password) {
		if(username.isEmpty() || password.isEmpty()){
			return null;
		}else{
			ClassPathResource res = new ClassPathResource("com/tbm/prode/services/beans.xml");
			XmlBeanFactory factory = new XmlBeanFactory(res);
			User user = (User)factory.getBean("user");
			currentUser = user;
			return user;
		}
	}

}
